import React, { Component } from 'react'
import Tap from '../common/tap/tap';
interface IState {
    arrlist: Array<any>,
    sonIndex: number
}
export default class Home extends Component<IState> {

    state = {
        arrlist: [
            {
                title: "首页房贷",
                cont: "首页的内容"
            },
            {
                title: "关注但是",
                cont: "关注页的内容"
            },
            {
                title: "喜欢",
                cont: "喜欢的内容",
            },
            {
                title: "vue",
                cont: "vue的内容",
            },
            {
                title: "react",
                cont: "react的内容"
            },
            {
                title: "首页",
                cont: "首页的内容"
            },
            {
                title: "关注",
                cont: "关注页的内容"
            },
            {
                title: "喜欢",
                cont: "喜欢的内容",
            },
            {
                title: "vue",
                cont: "vue的内容",
            },
            {
                title: "react",
                cont: "react的内容"
            }
        ],
        nowIndex: 0,
        sonIndex: 0,


    }
    render() {
        let { arrlist, nowIndex } = this.state;
        return (
            <div>
                <Tap arrlist={arrlist} getnowIndex={this.getnowIndex}>
                    {/* 匿名插槽 */}
                    {
                        arrlist.map((item, index) => {
                            return <h2 key={index}>{item.cont}</h2>
                        })
                    }
                </Tap>
            </div>
        )
    }
    getnowIndex = (index: number) => {
        this.setState({ sonIndex: index }, () => {
            if(this.state.sonIndex===0){
                return ;
            }
            console.log(this.state.sonIndex);
            

        })
    }
}
